package com.gmadmin.common;

import com.aventrix.jnanoid.jnanoid.NanoIdUtils;

import java.time.LocalDateTime;

/**
 * 基础消息实体，包含基础的消息
 * 根据自己的业务消息设置更多的字段
 *
 * @author zhangliang
 * @version 1.0
 * @date 2022/7/28 10:46
 */
public abstract class BaseMqMessage {

    /**
     * 业务键，用于RocketMQ控制台查看消费情况
     */
    protected String key;
    /**
     * 发送消息来源，用于排查问题
     */
    protected String source = "";
    /**
     * 发送时间
     */
    protected LocalDateTime sendTime = LocalDateTime.now();
    /**
     * 跟踪id，用于slf4j等日志记录跟踪id，方便查询业务链
     */
    protected String traceId = NanoIdUtils.randomNanoId();
    /**
     * 重试次数，用于判断重试次数，超过重试次数发送异常警告
     */

    protected Integer retryTimes = 0;


    /**
     * 消息
     */
    protected String message = "";

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public LocalDateTime getSendTime() {
        return sendTime;
    }

    public void setSendTime(LocalDateTime sendTime) {
        this.sendTime = sendTime;
    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public Integer getRetryTimes() {
        return retryTimes;
    }

    public void setRetryTimes(Integer retryTimes) {
        this.retryTimes = retryTimes;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
